TARGET		= /home/nikola/lib/dimga


CXX			= g++ -c

CXXFLAGS	= -g -D_DEBUG -I.

OBJS=.obj/genotype.o .obj/vivarium.o .obj/dimga.o .obj/config.o .obj/csv.o .obj/btree.o

dimga: init $(OBJS)
	g++ -o bin/dimga $(OBJS) -ldl -lpthread

.obj/genotype.o: genotype.cpp
	$(CXX) $(CXXFLAGS) -o $@ $<;

.obj/vivarium.o: vivarium.cpp
	$(CXX) $(CXXFLAGS) -o $@ $<;

.obj/config.o: config.cpp config.h
	$(CXX) $(CXXFLAGS) -o $@ config.cpp

.obj/csv.o: csv.cpp csv.h
	$(CXX) $(CXXFLAGS) -o $@ csv.cpp

.obj/btree.o: btree.cpp btree.h
	$(CXX) $(CXXFLAGS) -o $@ btree.cpp

.obj/dimga.o: dimga.cpp 
	$(CXX) $(CXXFLAGS) -o $@ dimga.cpp;

example: .obj/example.o
	ld -g -shared -o bin/eval.so .obj/example.o;

gpeval: .obj/gpeval.o
	ld -g -shared -o bin/gpeval.so .obj/gpeval.o;

.obj/example.o: example.cpp
	g++ -fPIC -c -g -D_DEBUG -o $@ $<;

.obj/gpeval.o: gpeval.cpp
	g++ -fPIC -c -g -D_DEBUG -o $@ $<;

init: 
	@if [ -d bin ]; then echo ""; else mkdir bin; fi;
	@if [ -d .obj ]; then echo ""; else mkdir .obj; fi;

install:
	@mkdir -p $(TARGET) $(TARGET)/include $(TARGET)/bin;
	@cp ../genetic/gaevaluator.h $(TARGET)/include;
	@cp bin/dimga $(TARGET)/bin
	@echo "installed in " $(TARGET);

uninstall:
	@rm -rf $(TARGET);

clean: 
	rm -rf bin;
	rm -rf .obj;
	rm -rf eval.so;

